import { createRouter, createWebHashHistory } from 'vue-router'
// import HomeView from '@/views/HomeView.vue'
// import SearchView from '@/views/SearchView.vue'
// import NotFound from '@/views/NotFound.vue'

// 1. 创建一个全局的路由对象
const router = createRouter({
  // 1.1 配置路由模式
  // hash-->#/xx/xx, history-->/xx/xx
  history: createWebHashHistory(),
  // 1.2 路由规则数组
  routes: [
    {path: '/', redirect: '/home'},
    {name: 'home',  path: '/home', component: ()=>import('@/views/HomeView.vue')},
    // 配置动态路由
    // /searc/xxx
    // :words? 可选
    {name: 'search',  path: '/search/:words?', component: ()=>import('@/views/SearchView.vue')},
    // 前面都没有匹配上, 进入这里
    {path: '/:catchAll(.*)', component: ()=>import('@/views/NotFound.vue')}
  ]
})

// 2. 导出
export default router